package com.ruoyi.crm.service.impl;

import java.io.Serializable;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.crm.mapper.CrmApplyClearDetailsMapper;
import com.ruoyi.crm.domain.CrmApplyClearDetails;
import com.ruoyi.crm.service.ICrmApplyClearDetailsService;

/**
 * 申请结算费用详情中间Service业务层处理
 *
 * @author yanwenliang
 * @date 2024-12-16
 */
@Service
public class CrmApplyClearDetailsServiceImpl extends ServiceImpl<CrmApplyClearDetailsMapper, CrmApplyClearDetails> implements ICrmApplyClearDetailsService
{
    @Autowired
    private CrmApplyClearDetailsMapper crmApplyClearDetailsMapper;

    /**
     * 查询申请结算费用详情中间
     *
     * @param applyClearDetailsId 申请结算费用详情中间主键
     * @return 申请结算费用详情中间
     */
    @Override
    public CrmApplyClearDetails selectCrmApplyClearDetailsByApplyClearDetailsId(String applyClearDetailsId)
    {
        return crmApplyClearDetailsMapper.selectCrmApplyClearDetailsByApplyClearDetailsId(applyClearDetailsId);
    }

    /**
     * 查询申请结算费用详情中间列表
     *
     * @param crmApplyClearDetails 申请结算费用详情中间
     * @return 申请结算费用详情中间
     */
    @Override
    public List<CrmApplyClearDetails> selectCrmApplyClearDetailsList(CrmApplyClearDetails crmApplyClearDetails)
    {
        return crmApplyClearDetailsMapper.selectCrmApplyClearDetailsList(crmApplyClearDetails);
    }

    /**
     * 新增申请结算费用详情中间
     *
     * @param crmApplyClearDetails 申请结算费用详情中间
     * @return 结果
     */
    @Override
    public int insertCrmApplyClearDetails(CrmApplyClearDetails crmApplyClearDetails)
    {
        return crmApplyClearDetailsMapper.insertCrmApplyClearDetails(crmApplyClearDetails);
    }

    /**
     * 修改申请结算费用详情中间
     *
     * @param crmApplyClearDetails 申请结算费用详情中间
     * @return 结果
     */
    @Override
    public int updateCrmApplyClearDetails(CrmApplyClearDetails crmApplyClearDetails)
    {
        return crmApplyClearDetailsMapper.updateCrmApplyClearDetails(crmApplyClearDetails);
    }

    /**
     * 批量删除申请结算费用详情中间
     *
     * @param applyClearDetailsIds 需要删除的申请结算费用详情中间主键
     * @return 结果
     */
    @Override
    public int deleteCrmApplyClearDetailsByApplyClearDetailsIds(String[] applyClearDetailsIds)
    {
        return crmApplyClearDetailsMapper.deleteCrmApplyClearDetailsByApplyClearDetailsIds(applyClearDetailsIds);
    }

    /**
     * 删除申请结算费用详情中间信息
     *
     * @param applyClearDetailsId 申请结算费用详情中间主键
     * @return 结果
     */
    @Override
    public int deleteCrmApplyClearDetailsByApplyClearDetailsId(String applyClearDetailsId)
    {
        return crmApplyClearDetailsMapper.deleteCrmApplyClearDetailsByApplyClearDetailsId(applyClearDetailsId);
    }

    @Override
    public boolean insert(CrmApplyClearDetails entity) {
        entity.setApplyClearDetailsId(IdWorker.getIdStr());
        entity.setUserId(SecurityUtils.getUserId());
        return baseMapper.insert(entity) > 0;
    }

    @Override
    public List<CrmApplyClearDetails> list(Serializable id) {
        List<CrmApplyClearDetails> crmApplyClearDetails = baseMapper.selectList(new LambdaQueryWrapper<CrmApplyClearDetails>().eq(CrmApplyClearDetails::getClearDetailsId, id));
        return crmApplyClearDetails;
    }

    @Override
    public boolean remove(Serializable id) {
        return baseMapper.delete(new LambdaQueryWrapper<CrmApplyClearDetails>().eq(CrmApplyClearDetails::getClearDetailsId, id)) > 0;
    }
}
